﻿<Window x:Class="DataBinding.BindToXmlDataProvider"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="BindToXmlDataProvider" Height="300" Width="300"
    >
  <Window.Resources>
    <XmlDataProvider x:Key="products" Source="/store.xml" XPath="/Products"></XmlDataProvider>
  </Window.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*"></RowDefinition>
      <RowDefinition Height="Auto"></RowDefinition>
      <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>

      <ListBox Name="lstProducts" Margin="5" DisplayMemberPath="ModelName"
                ItemsSource="{Binding Source={StaticResource products},XPath=Product}" ></ListBox>

    <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" ResizeBehavior="PreviousAndNext"
                          
              Height="5"
    ></GridSplitter>
    <Border Grid.Row="2" Padding="7" Margin="7" Background="LightSteelBlue">
      <Grid DataContext="{Binding ElementName=lstProducts, Path=SelectedItem}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"></ColumnDefinition>
          <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <TextBlock Margin="7">Model Number:</TextBlock>
        <TextBox Margin="5" Grid.Column="1" Text="{Binding XPath=ModelNumber}"></TextBox>
        <TextBlock Margin="7" Grid.Row="1">Model Name:</TextBlock>
        <TextBox Margin="5" Grid.Row="1" Grid.Column="1" Text="{Binding XPath=ModelName}"></TextBox>
        <TextBlock Margin="7" Grid.Row="2">Unit Cost:</TextBlock>
        <TextBox Margin="5" Grid.Row="2" Grid.Column="1" Text="{Binding XPath=UnitCost}"></TextBox>
        <TextBlock Margin="7,7,7,0" Grid.Row="3">Description:</TextBlock>
        <TextBox Margin="7" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2"
                 TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" Text="{Binding XPath=Description}"></TextBox>


      </Grid>
    </Border>
  </Grid>
</Window>
